 /**
 * 逻辑、功能相关描述:入伙手续办理
 *
 * @author yandawei 编写日期：2008-12-31
 */
package com.ce.pms.occupation.web;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;

import com.ce.pms.base.web.PmsBaseAction;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.common.service.ISysrefcodeService;
import com.ce.pms.common.util.PmsUtilityComparator;
import com.ce.pms.common.web.ICacheManage;
import com.ce.pms.customer.model.IdTypeDO;
import com.ce.pms.customer.model.IndividualDO;
import com.ce.pms.customer.model.ParticipantDO;
import com.ce.pms.customer.service.IClientRHouseService;
import com.ce.pms.customer.service.IConstService;
import com.ce.pms.customer.service.ICustomerService;
import com.ce.pms.customer.vo.CustomerVO;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.house.model.CoalitionHouseDomain;
import com.ce.pms.house.model.HouseDomain;
import com.ce.pms.house.service.IBuildingService;
import com.ce.pms.house.service.IHouseService;
import com.ce.pms.house.service.IMeterService;
import com.ce.pms.house.vo.BuildingVO;
import com.ce.pms.house.vo.MeterVO;
import com.ce.pms.occupation.model.InspecteRequisiteDO;
import com.ce.pms.occupation.service.IDocumentReceiveSendService;
import com.ce.pms.occupation.service.IIdentityValidateService;
import com.ce.pms.occupation.service.IInspecteRequisiteService;
import com.ce.pms.occupation.service.IOccupationChargeService;
import com.ce.pms.occupation.service.IPerfectItemDispatchService;
import com.ce.pms.occupation.service.IPerfectItemRequisitionService;
import com.ce.pms.occupation.service.IThingHandoverService;
import com.ce.pms.occupation.vo.DocumentReceiveSendVO;
import com.ce.pms.occupation.vo.IdentityValidateVO;
import com.ce.pms.occupation.vo.InspecteRequisiteVO;
import com.ce.pms.occupation.vo.MeterCardinalNumberVO;
import com.ce.pms.occupation.vo.OccHouseClientInfoVO;
import com.ce.pms.occupation.vo.OccupationChargeVO;
import com.ce.pms.occupation.vo.OccupationQueryConditionVO;
import com.ce.pms.occupation.vo.PerfectItemRequisitionVO;
import com.ce.pms.occupation.vo.ThingHandoverItemVO;
import com.ce.pms.occupation.vo.ThingHandoverVO;
import com.ce.pms.system.occupation.service.IAbsentDocumentItemConfigService;
import com.ce.pms.system.occupation.service.IPerfectItemTypeConfigService;
import com.ce.pms.system.occupation.service.ISendDocumentItemConfigService;
import com.ce.pms.system.occupation.service.IThingHandoverCongfigService;
import com.ce.pms.system.occupation.vo.AbsentDocumentItemConfigVO;
import com.ce.pms.system.occupation.vo.PerfectItemTypeConfigVO;
import com.ce.pms.system.occupation.vo.SendDocumentItemConfigVO;
import com.ce.pms.system.occupation.vo.ThingHandoverCongfigVO;
import com.ce.util.BlankUtil;
import com.sitechasia.webx.components.xtable.util.ExtremeUtils;
import com.sitechasia.webx.core.annotation.Out;
import com.sitechasia.webx.core.annotation.Read;
import com.sitechasia.webx.core.annotation.Scope;
import com.sitechasia.webx.core.support.Page;
import com.sitechasia.webx.core.utils.base.PopulateUtil;

/**
 * @author yandawei
 *
 */
public class JoinHandleAction extends PmsBaseAction {

	private IIdentityValidateService identityValidateService;

	private IConstService constService;

	private IDocumentReceiveSendService documentReceiveSendService;

	private IAbsentDocumentItemConfigService absentDocumentItemConfigService;

	private ISendDocumentItemConfigService sendDocumentItemConfigService;

	private IBuildingService buildingService;

	private ICustomerService customerService;

	private ISysrefcodeService sysrefcodeService;

	private IClientRHouseService clientRHouseService;

	private IHouseService houseService;

	private IPerfectItemRequisitionService perfectItemRequisitionService;

	private IThingHandoverCongfigService thingHandoverCongfigService;

	private IThingHandoverService thingHandoverService;

	private IPerfectItemTypeConfigService perfectItemTypeConfigService;

	private IPerfectItemDispatchService perfectItemDispatchService;

	private IMeterService meterService;

	private IInspecteRequisiteService inspecteRequisiteService;

	private IOccupationChargeService occupationChargeService;

	//整改项目缓存
	public static final String PERFECT_ITEM_REQUSITE_CACHE = "perfectItemCache";



	/**
	 * 功能描述: 入伙手续办理主页面 <br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initJoinHandleMain(){
		//楼栋列表
		List<BuildingVO> buildList = buildingService.getAllBuildingList();
		Collections.sort(buildList, PmsUtilityComparator.getComparator());
		setAttribute("buildList", buildList);
		return "joinHandleMain";
	}

	/**
	 * 功能描述: 入伙手续办理详细页面 <br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getJoinHandleDetailMain(@Read(key="id")Long id){
		IdentityValidateVO identityValidateVO =  identityValidateService.getIdentityValidateDetail(id);
		Set<OccHouseClientInfoVO> otherSet = identityValidateVO.getClientInfos();
		Iterator it = otherSet.iterator();
		String coalitionHouseNumber = null;
		while(it.hasNext()){
			OccHouseClientInfoVO clientInfoVO = (OccHouseClientInfoVO) it.next();
			coalitionHouseNumber = clientInfoVO.getCoalitionHouseNumber();
			break;
		}
		splitRealHouseClientInfo(otherSet);
		//相关业主
		setAttribute("clientInfoSet", otherSet);
		//管理房
		setAttribute("coalitionHouseNumber", coalitionHouseNumber);
		//身份验证
		setAttribute("identityItem", identityValidateVO);
		return "joinHandleDetailMain";
	}

	/**
	 * 功能描述: 入伙手续办理详细页面(身份验证分帧页) <br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getJoinHandleIdentityDetail(@Read(key="id")Long id){
		IdentityValidateVO identityValidateVO =  identityValidateService.getIdentityValidateDetail(id);
		//设置委托人证件类型名称
		if("002".equals(identityValidateVO.getTransactJoinIdentity())){
			List<IdTypeDO> list =  this.constService.getCertificateType();
			for (IdTypeDO type : list) {
				if (type.getIdTypeId().equals(identityValidateVO.getConsignAgentIdTypeId())) {
					identityValidateVO.setConsignAgentIdTypeName(type.getIdTypeName());
					break;
				}
			}
		}
		//身份验证
		setAttribute("identityValidate", identityValidateVO);
		return "joinHandleIdentityDetail";
	}

	/**
	 * 功能描述:  入伙手续办理详细页面(资料收发分帧页)<br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getJoinHandleDocDetail(@Read(key="id")Long identityId){
		DocumentReceiveSendVO documentReceiveSendVO = documentReceiveSendService.getDocumentReceiveSendBy(identityId);
		List<AbsentDocumentItemConfigVO> alist =  new ArrayList<AbsentDocumentItemConfigVO>();
		List<SendDocumentItemConfigVO> slist = new ArrayList<SendDocumentItemConfigVO>();
		BigDecimal total = new BigDecimal(0.00);
		if(!BlankUtil.isBlank(documentReceiveSendVO)){
			Set<AbsentDocumentItemConfigVO>  absentConfigs = documentReceiveSendVO.getAbsentDocumentItemConfigs();
			Set<SendDocumentItemConfigVO> sendConfigs = documentReceiveSendVO.getSendDocumentItemConfigs();
			alist.addAll(absentConfigs);
			Collections.sort(alist, PmsUtilityComparator.getComparator());
			slist.addAll(sendConfigs);
			Collections.sort(slist, PmsUtilityComparator.getComparator());
			IdentityValidateVO identityValidateVO =  documentReceiveSendVO.getIdentityValidate();
			//物业管理预缴费用
			total = occupationChargeService.getTotalPaySum(identityValidateVO.getKeyword(),identityValidateVO.getHouseId(), identityValidateVO.getJoinMode());
		}
		//物业管理预缴费用
		setAttribute("total", total);
		//缺失资料
		setAttribute("absentConfigSet", alist);
		//发送资料
		setAttribute("sendConfigSet", slist);
		setAttribute("documentReceiveSend", documentReceiveSendVO);
		return "joinHandleDocDetail";
	}


	/**
	 * 功能描述:  入伙手续办理详细页面(验房登记分帧页)<br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getJoinHandleHouseDetail(@Read(key="id")@Out(key="identityId")Long id){
		List<InspecteRequisiteVO> list = inspecteRequisiteService.queryInspecteRequisiteByIdentityValidateId(id);
		//设置验房记录序号(只需显示,与业务无关)
		if(!BlankUtil.isBlank(list)){
			for (int i = 0; i < list.size(); i++) {
				list.get(i).setSequence(i+1);
			}
			setAttribute("houseValidateList", list);
			setAttribute("totalRows",Integer.valueOf(list.size()));
		}else{
			setAttribute("houseValidateList", new ArrayList());
			setAttribute("totalRows",new Integer(0));
		}
		return "joinHandleHouseDetail";
	}

	/**
	 * 功能描述:  入伙手续办理详细页面(物品移交分帧页)<br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getJoinHandleGoodsDetail(@Read(key="id")@Out(key="identityId")Long id){
		List<ThingHandoverItemVO> list = null;
		ThingHandoverVO thingHandover = thingHandoverService.getHandoverByIndentityId(id);

		if(BlankUtil.isBlank(thingHandover) ||(!BlankUtil.isBlank(thingHandover)
				&& BlankUtil.isBlank(thingHandover.getThingHandoverItems()))){
			list = new ArrayList<ThingHandoverItemVO>();
		}else{
			Set<ThingHandoverItemVO> set  = thingHandover.getThingHandoverItems();
			Iterator<ThingHandoverItemVO> it =set.iterator();
			while (it.hasNext()) {
				ThingHandoverItemVO element = (ThingHandoverItemVO) it.next();
				if(element.getAmount()== 0){
					it.remove();
				}
			}
			list = convertThingHandoverItemSet2List(set);
			Collections.sort(list, PmsUtilityComparator.getComparator());
		}

		setAttribute("goodsSet", list);
		setAttribute("thingHandover", thingHandover);
		setAttribute("totalRows",new Integer(list.size()));
		return "joinHandleGoodsDetail";
	}

	/**
	 * 功能描述: 入伙手续高级查询页面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String joinHandelSeniorSearch(){
		//楼栋列表
		List<BuildingVO> buildList = buildingService.getAllBuildingList();
		Collections.sort(buildList, PmsUtilityComparator.getComparator());
		setAttribute("buildList", buildList);
		return "joinHandleSearch";
	}

	/**
	 * 功能描述:  入伙流程界面显示<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-19  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String joinHandleFlow(){
		return "joinHandleFlow";
	}

	/**
	 * 功能描述:  身份验证主界面<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initIdentityValidateMain(){
		return "identityValidateMain";
	}

	/**
	 * 功能描述:  将查询条件设置到缓存<br>
	 * @param processorId 数据字典表入伙进程ID
	 * @param queryConditionVO 查询条件
	 * Create author:yandawei <br>
	 * Create on:2009-1-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void setIdentityConditionCache(
			@Read(key="processor")Long processorId,
			@Read  OccupationQueryConditionVO queryConditionVO){
		setProcessorStatus(processorId, queryConditionVO);
		setAttribute("joinCondition", queryConditionVO, Scope.SESSION);
	}



	/**
	 * 功能描述:  刷新身份验证列表<br>
	 * @param pageNO
	 * @param pageSize
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String identityValidateList(
			@Read(key = "ec_p", defaultValue = "1") Integer pageNO,
			@Read(key = "ec_crd",defaultValue = "10")Integer pageSize,
			@Read(key = "overflowHight",defaultValue = "")@Out(key="overflowHight")String overflowHight){
		OccupationQueryConditionVO queryConditionVO = getIdentityConditionFromCache();
		queryConditionVO.setPageNo(pageNO);
		queryConditionVO.setPageSize(pageSize);
		String sortStr=ExtremeUtils.getOrderString(this.getRequest());
		queryConditionVO.setSortStr(sortStr);
		Page page = identityValidateService.queryIdentityValidateList(queryConditionVO);
		if(!BlankUtil.isBlank(page)){
			setAttribute("identityList", page.getResult());
			setAttribute("totalRows",Integer.valueOf(String.valueOf(page.getTotalCount())));
		}else{
			setAttribute("totalRows",new Integer(0));
		}
		return "initIdentityValidateList";
	}


	/**
	 * 功能描述:  初始化身份验证列表<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-16  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initIdentityValidateList(){
		setIdentityConditionCache(null, new OccupationQueryConditionVO());
		setAttribute("totalRows",new Integer(0));
		return "initIdentityValidateList";
	}

	/**
	 * 功能描述:  初始化新增身份验证<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initIdentityValidateAdd(){
		//证件类型
		List<IdTypeDO> list =  this.constService.getCertificateType();
		setAttribute("certificateTypeList", list);
		return "identityValidateAdd";
	}

	/**
	 * 功能描述:  根据房间ID查出关联房信息与业主姓名,证件类型,证件号码,以json数组返回前台<br>
	 * @param houseId
	 * Create author:yandawei <br>
	 * Create on:2009-1-4  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void queryCustomerHouse(@Read(key="houseId") Long houseId)
	{
		List<Object[]> lists = new ArrayList<Object[]>();
	    CoalitionHouseDomain coalitionHouseDomain =	houseService.getCoalition(houseId);
	    //如果没有管理房
	    if(BlankUtil.isBlank(coalitionHouseDomain)){
	    	buildClientInfo(houseId, lists,coalitionHouseDomain);
	    }else{
		    Set<HouseDomain> houseSet = coalitionHouseDomain.getHouses();
		    for(HouseDomain house : houseSet){
		    	buildClientInfo(house.getKeyword(), lists, coalitionHouseDomain);
		    }
	    }
	    if(BlankUtil.isBlank(lists)){
	    	this.renderText("false");
	    }else{
			StringBuffer jsonStr = new StringBuffer("[");
			for(Object[] objs : lists){
				jsonStr.append("{\"houseId\" : \""+ objs[0] +"\",");
				jsonStr.append("\"houseNumber\" : \""+ objs[1] +"\",");
				jsonStr.append("\"coalitionHouseNumber\" : \""+ objs[2] +"\",");
				jsonStr.append("\"ownerName\" :\""+ objs[3] +"\",");
				jsonStr.append("\"certificateTypeStr\" : \""+ objs[4] +"\",");
				jsonStr.append("\"certificateNumberStr\" : \""+ objs[5] +"\"},");
			}
			jsonStr = jsonStr.deleteCharAt(jsonStr.length()-1);
			jsonStr.append("]");
			this.renderText(jsonStr.toString());
	    }
	}




	/**
	 * 功能描述:  新增身份验证<br>
	 * @param identityValidateVO
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addIdentityValidate(@Read IdentityValidateVO identityValidateVO){
		buildHouseClientInfo(identityValidateVO.getClientInfo(),identityValidateVO);
		identityValidateVO.setCreator(getUserId());
		identityValidateService.addIdentityValidate(identityValidateVO);
		this.renderText("true");
	}



	/**
	 * 功能描述: 初始化修改身份验证 <br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initIdentityValidateEdit(@Read(key="id")Long id){
		setClientBaseInfo(id, false);
		IdentityValidateVO identityValidateVO =  (IdentityValidateVO) getAttribute("identityValidate");
		//注意:如果在修改前修改了房间业主信息(改名或删除),不能保证数据正确性
		List<ParticipantDO> partlist = clientRHouseService.getAllOwnerByHouseId(identityValidateVO.getHouseId());
		List<IdTypeDO> list =  this.constService.getCertificateType();
		setAttribute("certificateTypeList", list);

		//业主列表
		setAttribute("clientInfoList", partlist);
		return "identityValidateEdit";
	}




	/**
	 * 功能描述:  修改身份验证<br>
	 * @param identityValidateVO
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void editIdentityValidate(@Read IdentityValidateVO identityValidateVO){
		identityValidateVO.setModifier(getUserId());
		identityValidateService.editIdentityValidate(identityValidateVO);
		this.renderText("true");
	}


	/**
	 * 功能描述:  验证删除身份验证(为true可以删除,否则不能删除)<br>
	 * @param identityValidateId
	 * Create author:yandawei <br>
	 * Create on:2009-1-21  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void checkIdentityValidateDelete(@Read(key="id") Long identityValidateId){
		boolean result = identityValidateService.isAllowDelIdentityValidate(identityValidateId);
		if(result){
			this.renderText("true");
		}else{
			this.renderText("false");
		}
	}

	/**
	 * 功能描述:  删除身份验证<br>
	 * @param identityValidateId
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void deleteIdentityValidate(@Read(key="id") Long identityValidateId){
		identityValidateService.delIdentityValidate(identityValidateId);
		this.renderText("true");
	}

	/**
	 * 功能描述: 初始化资料收发 <br>
	 * @param identityValidateId 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initSendDoc(@Read(key="id")@Out(key="identityValidateId")Long identityValidateId){
		setClientBaseInfo(identityValidateId, true);
		DocumentReceiveSendVO documentReceiveSendVO = documentReceiveSendService.getDocumentReceiveSendBy(identityValidateId);
		List<SendDocumentItemConfigVO> sendDocumentItemConfigs = sendDocumentItemConfigService.queryAllSendDocumentItemConfig();
		List<AbsentDocumentItemConfigVO> absentDocumentItemConfigs = absentDocumentItemConfigService.queryAllAbsentDocumentItemConfig();
		if(!BlankUtil.isBlank(documentReceiveSendVO)){
			StringBuffer sendDocumentItemConfigStr = new StringBuffer();
			StringBuffer absentDocumentItemConfigStr = new StringBuffer();
			for(SendDocumentItemConfigVO  configVO:documentReceiveSendVO.getSendDocumentItemConfigs()){
				sendDocumentItemConfigStr.append(configVO.getKeyword()).append(",");
			}
			//如果有选中的收发资料保存其ID串
			documentReceiveSendVO.setSendDocumentItemConfigStr(sendDocumentItemConfigStr.toString());
			for(AbsentDocumentItemConfigVO  configVO:documentReceiveSendVO.getAbsentDocumentItemConfigs()){
				absentDocumentItemConfigStr.append(configVO.getKeyword()).append(",");
			}
			documentReceiveSendVO.setAbsentDocumentItemConfigStr(absentDocumentItemConfigStr.toString());
		}

		IdentityValidateVO identityValidateVO =  (IdentityValidateVO) getAttribute("identityValidate");
		//物业管理预缴费用
		BigDecimal total = occupationChargeService.getTotalPaySum(identityValidateVO.getKeyword(),identityValidateVO.getHouseId(), identityValidateVO.getJoinMode());
		//发放资料
		Collections.sort(sendDocumentItemConfigs, PmsUtilityComparator.getComparator());
		setAttribute("sendDocConfig", sendDocumentItemConfigs);
		//缺失资料
		Collections.sort(absentDocumentItemConfigs, PmsUtilityComparator.getComparator());
		setAttribute("absentDocConfig", absentDocumentItemConfigs);
		//本体
		setAttribute("documentReceiveSend",documentReceiveSendVO);
		setAttribute("total", total);
		return "sendDocEdit";
	}

	/**
	 * 功能描述:  资料收发(新增与修改)<br>
	 * @param identityValidateId 身份验证ID
	 * @param documentReceiveSendVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void editSendDoc(
			@Read(key="identityValidateId")Long identityValidateId,
			@Read DocumentReceiveSendVO documentReceiveSendVO){
		String result = "true";
		int i =0;
		IdentityValidateVO identityValidateVO = identityValidateService.getIdentityValidateDetail(identityValidateId);
		OccupationChargeVO occupationChargeVO = new OccupationChargeVO(identityValidateVO,getUserId());
		try {
			 occupationChargeService.addOccupationCharge(occupationChargeVO);
		} catch (Exception e) {
			result = getLocaleMessage(e.getMessage());
			i++;
		}
		try{
		documentReceiveSendVO.setIdentityValidate(identityValidateVO);
		setCollection2DocumentReceiveSend(documentReceiveSendVO);
		documentReceiveSendService.addDocumentReceiveSend(documentReceiveSendVO);
		}catch(Exception e){
			result = getLocaleMessage(e.getMessage());
			i++;
		}

		if(i == 2){
			this.renderText("资料收发与物业管理费预缴失败!");
		}
		else
			this.renderText(result);
	}



	/**
	 * 功能描述: 初始化移交物品主页面 <br>
	 * @param id 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initGoodsTransfer(@Read(key="id")@Out(key="identityId")Long id){
		setClientBaseInfo(id, true);
		ThingHandoverVO thingHandover = thingHandoverService.getHandoverByIndentityId(id);
		setAttribute("thingHandover", thingHandover);
		//接受人列表
		setAttribute("handoverList", buildClientInfoList(id));
		return "goodsTransferEdit";
	}


	/**
	 * 功能描述: 移交物品(新增与修改) <br>
	 * @param thingHandoverVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-13  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void editGoodsTransfer(
			@Read(key="identityValidateId")Long identityValidateId,
			@Read ThingHandoverVO thingHandoverVO){
		Set<ThingHandoverItemVO> set = buildThingHandoverItemStr2Set(thingHandoverVO.getThingHandoverItemStr(),identityValidateId);
		IdentityValidateVO identityValidateVO = new IdentityValidateVO();
		identityValidateVO.setKeyword(identityValidateId);
		thingHandoverVO.setIdentityValidate(identityValidateVO);
		thingHandoverVO.setThingHandoverItems(set);
		thingHandoverService.addThingHandover(thingHandoverVO);
		this.renderText("true");
	}



	/**
	 * 功能描述: 移交物品列表 <br>
	 * @param identityId 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initGoodsList(@Read(key="identityId")Long identityId){
		Set<ThingHandoverItemVO> set = null;
		ThingHandoverVO thingHandover = thingHandoverService.getHandoverByIndentityId(identityId);
		//无移交物品记录或有移交物品记录但没有移交列表时显示默认配置信息
		if(BlankUtil.isBlank(thingHandover) ||(!BlankUtil.isBlank(thingHandover)) && BlankUtil.isBlank(thingHandover.getThingHandoverItems())){
			set = getDefaultThingHandoverItemSet(identityId);
		}else{
			set = thingHandover.getThingHandoverItems();
		}
		List<ThingHandoverItemVO> list = convertThingHandoverItemSet2List(set);
		Collections.sort(list, PmsUtilityComparator.getComparator());
		setAttribute("goodsSet", list);
		setAttribute("totalRows",new Integer(list.size()));
		return "goodsList";
	}



	/**
	 * 功能描述:  初始化验房登记主页面<br>
	 * @param identityId 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-12-31  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initHouseValidateMain(@Read(key="id")@Out(key="id")Long identityId){
		setClientBaseInfo(identityId,true);
		return "houseValidateMain";
	}



	/**
	 * 功能描述:  跳转到包含验房列表的界面<br>
	 * @param identityId 身份验证ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initHouseValidate(@Read(key="id")@Out(key="id") Long identityId){
		return "houseValidate";
	}

	/**
	 * 功能描述:  验房信息列表<br>
	 * @param identityId 身份验证ID
	 * @param pageNO
	 * @param pageSize
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initHouseValidateList(
			@Read(key="id")@Out(key="id") Long identityValidateId,
			@Read(key = "ec_p", defaultValue = "1") Integer pageNO,
			@Read(key = "ec_crd",defaultValue = "10")Integer pageSize){
		List<InspecteRequisiteVO> list = inspecteRequisiteService.queryInspecteRequisiteByIdentityValidateId(identityValidateId);
		//设置显示序号
		if(!BlankUtil.isBlank(list)){
			for (int i = 0; i < list.size(); i++) {
				list.get(i).setSequence(i+1);
			}
		}
		if(!BlankUtil.isBlank(list)){
			setAttribute("houseValidateList", list);
			setAttribute("totalRows",Integer.valueOf(String.valueOf(list.size())));
		}else{
			setAttribute("houseValidateList", new ArrayList());
			setAttribute("totalRows",new Integer(0));
		}
		return "houseValidateList";
	}

	/**
	 * 功能描述:  验房验证 ture为可以进行操作<br>
	 * @param optType 操作类型add/edit/delete
	 * @param inspecteRequisiteId 验房ID
	 * @param identityValidateId 身份验证ID
	 * Create author:yandawei <br>
	 * Create on:2009-1-19  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void checkAllowHouseValidate(
			@Read(key="optType")String optType,
			@Read(key="inspecteRequisiteId")Long inspecteRequisiteId,
			@Read(key="identityValidateId")Long identityValidateId){
		String result = "";
		boolean flag = true;
		if("add".equals(optType)){
			flag = inspecteRequisiteService.isAllowAddInspecteRequisite(identityValidateId);
			if(!flag)
				result = "false";
		}else if("edit".equals(optType)){
			InspecteRequisiteDO inspecteDO =inspecteRequisiteService.isAllowEditInspecteRequisite(inspecteRequisiteId);
			if(BlankUtil.isBlank(inspecteDO)){
				result = "false";
			}

		}else if("delete".equals(optType)){
			flag  = inspecteRequisiteService.isAllowDeleteInspecteRequisite(inspecteRequisiteId);
			if(!flag)
				result = "false";
		}
		this.renderText(result);
	}

	/**
	 * 功能描述:  整改项目删除验证<br>
	 * @param id 整改项目ID
	 * Create author:yandawei <br>
	 * Create on:2009-1-20  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void checkPerfectItemRequiste(@Read(key="id")Long id){
		perfectItemDispatchService.checkDeletePerfectItemIsTrue(id);
		this.renderText("true");
	}

	/**
	 * 功能描述: 初始化验房操作主界面（新增与修改） <br>
	 * @param identityId  身份验证ID
	 * @param requisteId   验房ID
	 * @param optType 操作类型add/edit
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initHouseValidateBaseMain(
			@Read(key="id")Long identityId,
			@Read(key="keyword")Long inspecteRequisteId,
			@Read(key="optType")@Out(key="optType")String optType){
		clearCache();
		setClientBaseInfo(identityId,true);
		InspecteRequisiteVO inspectRequisite =  new InspecteRequisiteVO();
		if("edit".equals(optType)){
			inspectRequisite =  inspecteRequisiteService.getInspectRequisitionDetail(inspecteRequisteId);
			Set<PerfectItemRequisitionVO> set = inspectRequisite.getPerfectItemRequisitions();
			//将查询出来的整改项目添加到缓存
			for(PerfectItemRequisitionVO itemRequisitionVO : set){
				this.addPerfectItemRequistionToCache(itemRequisitionVO, false);
			}
			setAllStatusToDone();
		}
		inspectRequisite.setIdentityValidateId(identityId);
		setAttribute("inspectRequisite",inspectRequisite);
		//验收人列表
		setAttribute("handoverList", buildClientInfoList(identityId));
		setAttribute("inspecteRequisteId", inspecteRequisteId);
		return "houseValidateBaseMain";
	}



	/**
	 * 功能描述: 获取验房的详细记录 <br>
	 * @param identityValidateId   身份验证ID
	 * @param inspecteRequisiteId   验房ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getHouseValidateDetail(
			@Read(key="identityId")Long identityValidateId,
			@Read(key="id")Long inspecteRequisiteId){
	    InspecteRequisiteVO inspecteRequisiteVO = inspecteRequisiteService.getInspectRequisitionDetail(inspecteRequisiteId);
	    //验房信息
	    setAttribute("inspectRequisite", inspecteRequisiteVO);
		setClientBaseInfo(identityValidateId,true);
		return "houseValidateDetail";
	}

	/**
	 * 功能描述: 初始化整改项目的主界面 <br>
	 * @param identityValidateId 身份验证ID
	 * @param inspecteRequisteId 验房ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRectificateMain(
			@Read(key="identityValidateId")@Out(key="identityValidateId")Long identityValidateId,
			@Read(key="inspecteRequisteId")@Out(key="inspecteRequisteId")Long inspecteRequisteId){
		return "rectificateMain";
	}


	/**
	 * 功能描述: 整改项目列表(缓存) <br>
	 * @param inspecteRequisteId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRectificateListCache(@Read(key="id")Long inspecteRequisteId){
		List<PerfectItemRequisitionVO> list = this.getPerfectItemRequisitionListCacheByFlag(true);
		setAttribute("rectificateList", list);
		setAttribute("totalRows",getTotalRowsFromCache());
		//验房登记操作时的整改列表
		setAttribute("status", "houseValidate");
		return "rectificateList";
	}
	/**
	 * 功能描述: 功能描述: 整改项目列表 <br>
	 * @param inspecteRequisiteId  验房ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-12  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRectificateList(@Read(key="id")Long inspecteRequisiteId){
		List<PerfectItemRequisitionVO> list = perfectItemRequisitionService.queryPerItemListByInspReqId(inspecteRequisiteId);
		int index = 1;
		if(!BlankUtil.isBlank(list)){
			for (Iterator iter = list.iterator(); iter.hasNext();) {
				PerfectItemRequisitionVO element = (PerfectItemRequisitionVO) iter.next();
				element.setIndex(index++);
			}
		}
		setAttribute("rectificateList", list);
		setAttribute("totalRows",new Integer(list == null ? 0: list.size()));
		//验房登记查看时的整改列表
		setAttribute("status", "detail");
		return "rectificateList";
	}




	/**
	 * 功能描述:  初始化整改项目新增界面<br>
	 * @param identityValidateId 身份验证ID
	 * @param inspecteRequisiteId  验房ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRectificateAdd(
			@Read(key="identityValidateId")Long identityValidateId,
			@Read(key="id")Long inspecteRequisiteId){
		List<PerfectItemTypeConfigVO> list = perfectItemTypeConfigService.queryAllPerfectItemTypeConfig();
	    IdentityValidateVO identityValidateVO =	identityValidateService.getIdentityValidateDetail(identityValidateId);
		//指定验房ID
		PerfectItemRequisitionVO itemRequisitionVO = new PerfectItemRequisitionVO();
		itemRequisitionVO.setInspectionRequisitionId(inspecteRequisiteId);
		itemRequisitionVO.setHouseNumber(identityValidateVO.getHouseNumber());
		itemRequisitionVO.setOwnerName(identityValidateVO.getClientName());
		itemRequisitionVO.setJoinMode(identityValidateVO.getJoinMode());
		setAttribute("perfectItemRequisition", itemRequisitionVO);
		//整改申报类型列表
		Collections.sort(list, PmsUtilityComparator.getComparator());
		setAttribute("perfectItemTypeConfigList", list);
		//身份验证
		setAttribute("identityValidate", identityValidateVO);
		setAttribute("flag", "add");
		return "rectificateEdit";
	}

	/**
	 * 功能描述:  新增整改项目<br>
	 * @param perfectItemRequisitionVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addPerfectItemRequistion(@Read PerfectItemRequisitionVO perfectItemRequisitionVO){
		boolean result = addPerfectItemRequistionToCache(perfectItemRequisitionVO, true);
		if(result)
			this.renderText("true");
		else
			this.renderText("false");
	}

	/**
	 * 功能描述: 初始化整改项目修改界面(缓存) <br>
	 * @param index
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initRectificateEdit(@Read(key="index")Integer index){
		PerfectItemRequisitionVO itemRequisitionVO = getPerfectItemRequisitionByIndexFromCache(index);
		List<PerfectItemTypeConfigVO> list = perfectItemTypeConfigService.queryAllPerfectItemTypeConfig();
		Collections.sort(list, PmsUtilityComparator.getComparator());
		setAttribute("perfectItemTypeConfigList", list);
		setAttribute("perfectItemRequisition", itemRequisitionVO);
		setAttribute("flag", "update");
		return "rectificateEdit";
	}


	/**
	 * 功能描述:  修改整改项目(缓存)<br>
	 * @param perfectItemRequisitionVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void editPerfectItemRequistion(@Read PerfectItemRequisitionVO perfectItemRequisitionVO){
		boolean result = editPerfectItemRequistionFromCache(perfectItemRequisitionVO);
		if(result)
			this.renderText("true");
		else
			this.renderText("false");
	}


	/**
	 * 功能描述: 删除整改项目(缓存) <br>
	 * @param index
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void deltePerfectItemRequistion(@Read(key="index") Integer index){
		PerfectItemRequisitionVO itemRequisitionVO = getPerfectItemRequisitionByIndexFromCache(index);
		boolean result = false;
		if(!BlankUtil.isBlank(itemRequisitionVO.getKeyword())){
			perfectItemRequisitionService.checkDeleteIsTrue(itemRequisitionVO.getKeyword());
		}
		result = deletePerfectItemRequistionFromCache(itemRequisitionVO);
		if(result)
			this.renderText("true");
		else
			this.renderText("false");
	}


	/**
	 * 功能描述:  查看整改项目详细信息<br>
	 * @param index
	 * @param id
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-13  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String getRectificateDetail(
			@Read(key="index")Integer index,
			@Read(key="id")Long id){
		PerfectItemRequisitionVO itemRequisitionVO  = null;
		if(BlankUtil.isBlank(id)){
			itemRequisitionVO = getPerfectItemRequisitionByIndexFromCache(index);
		}else{
			itemRequisitionVO = perfectItemRequisitionService.queryPerfectItemRequisitionVOById(id);
		}
		setAttribute("perfectItemRequisition", itemRequisitionVO);
		return "rectificateDetail";
	}

	/**
	 * 功能描述:  修改验房登记<br>
	 * @param optType
	 * @param inspecteRequisiteVO
	 * @param meterCardinalStr 走表数据串
	 * Create author:yandawei <br>
	 * Create on:2009-1-16  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void editHouseValidate(
			@Read(key="optType")String optType,
			@Read InspecteRequisiteVO inspecteRequisiteVO,
			@Read(key="meterCardinalStr")String meterCardinalStr){
		Set<MeterCardinalNumberVO> set = buildMeterCardinalByStr(meterCardinalStr);
		//走表集合
		inspecteRequisiteVO.setMeterCardinalNumbers(set);
		//整改项目集合

		IdentityValidateVO identityValidate = new IdentityValidateVO();
		identityValidate.setKeyword(inspecteRequisiteVO.getIdentityValidateId());
		inspecteRequisiteVO.setIdentityValidate(identityValidate);
		if("add".equals(optType)){
			inspecteRequisiteVO.setPerfectItemRequisitions(convertPerfectItemList2Set(getPerfectItemRequisitionListCacheByFlag(true)));
			inspecteRequisiteService.addInspecteRequisite(inspecteRequisiteVO);
		}else if("edit".equals(optType)){
			inspecteRequisiteVO.setPerfectItemRequisitions(convertPerfectItemList2Set(getPerfectItemRequisitionListCacheByFlag(false)));
			inspecteRequisiteService.editInspecteRequisite(inspecteRequisiteVO);
		}
		this.renderText("true");
	}

	/**
	 * 功能描述:  删除验房记录<br>
	 * @param inspecteRequisteId
	 * Create author:yandawei <br>
	 * Create on:2009-1-13  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void deleteHouseValidate(@Read(key="keyword")Long inspecteRequisteId){
		inspecteRequisiteService.deleteInspecteRequisite(inspecteRequisteId);
		this.renderText("true");
	}



	/**
	 * 功能描述: 验房走表记录 <br>
	 * @param inspecteId 验房ID
	 * @param coalitionHouseNumber 管理房号
	 * @param houseNumberStr 产权房串
	 * @param optType 操作类型(add|edit)
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String initMeterDataList(
			@Read(key="inspecteId")Long inspecteRequisiteId,
			@Read(key="coalitionHouseNumber")String coalitionHouseNumber,
			@Read(key="houseIds")String houseIdStr,
			@Read(key="optType")String optType){
		//新增操作从房间走表中读数据加到走表列表
		String[] houseIds = houseIdStr.split(",");
		if("add".equals(optType)){
			List<MeterCardinalNumberVO> list = new ArrayList<MeterCardinalNumberVO>();
			for(String houseId :houseIds){
			 MeterCardinalNumberVO cardinalNumberVO = copyMeterDataToMeterCardinalBy(houseId,null);
			 cardinalNumberVO.setCoalitionHouseNumber(coalitionHouseNumber);
			 list.add(cardinalNumberVO);
			 //序号
			 cardinalNumberVO.setSequence((short)(list.size()));
			}
			setAttribute("meterDataList", list);
			setAttribute("totalRows",Integer.valueOf(list.size()));
		}else {
			InspecteRequisiteVO inspecteRequisiteVO = inspecteRequisiteService.getInspectRequisitionDetail(inspecteRequisiteId);
			Set<MeterCardinalNumberVO> set = inspecteRequisiteVO.getMeterCardinalNumbers();
			short index = 1;
			if(!BlankUtil.isBlank(set)){
				for (Iterator iter = set.iterator(); iter.hasNext();) {
					MeterCardinalNumberVO element = (MeterCardinalNumberVO) iter.next();
					for(String houseId :houseIds){
						copyMeterDataToMeterCardinalBy(houseId, element);
					}
					element.setCoalitionHouseNumber(coalitionHouseNumber);
					element.setSequence(index++);
				}
			}
			if(!BlankUtil.isBlank(set)){
				setAttribute("meterDataList",set);
				setAttribute("totalRows",Integer.valueOf(String.valueOf(set.size())));
			}else{
				setAttribute("totalRows",new Integer(0));
			}
		}
		//如果有操作类型则显示验房走表列表，如果没有则显示详细列表
		setAttribute("status", optType == null?"detail":"houseValidate");
		return "meterDataList";
	}
	/**
	 * 功能描述:验证房号是否存在<br>
	 * @param houseNumber
	 * Create author:yixianjian <br>
	 * Create on:2009-1-20  <br>
	 */
	public void validationHouseNumber(@Read(key="houseNumber")String houseNumber){
		String flag = null;
		if(houseNumber == null || "".equals(houseNumber))
			return;
		 //验证房号是否存在
		HouseDomain houseDomain = houseService.getHouseByNumber(houseNumber.trim());
		if(houseDomain == null)
			flag = getLocaleMessage("charge:charge_meterDataRegister_houseNumber_noexist");
		renderText(flag == null ? houseDomain.getKeyword().toString() : "false");
	}


	public void setAbsentDocumentItemConfigService(
			IAbsentDocumentItemConfigService absentDocumentItemConfigService) {
		this.absentDocumentItemConfigService = absentDocumentItemConfigService;
	}

	public void setBuildingService(IBuildingService buildingService) {
		this.buildingService = buildingService;
	}

	public void setDocumentReceiveSendService(
			IDocumentReceiveSendService documentReceiveSendService) {
		this.documentReceiveSendService = documentReceiveSendService;
	}

	public void setSendDocumentItemConfigService(
			ISendDocumentItemConfigService sendDocumentItemConfigService) {
		this.sendDocumentItemConfigService = sendDocumentItemConfigService;
	}

	public void setSysrefcodeService(ISysrefcodeService sysrefcodeService) {
		this.sysrefcodeService = sysrefcodeService;
	}

	public void setClientRHouseService(IClientRHouseService clientRHouseService) {
		this.clientRHouseService = clientRHouseService;
	}

	public void setThingHandoverCongfigService(
			IThingHandoverCongfigService thingHandoverCongfigService) {
		this.thingHandoverCongfigService = thingHandoverCongfigService;
	}

	public void setPerfectItemTypeConfigService(
			IPerfectItemTypeConfigService perfectItemTypeConfigService) {
		this.perfectItemTypeConfigService = perfectItemTypeConfigService;
	}



	public void setInspecteRequisiteService(
			IInspecteRequisiteService inspecteRequisiteService) {
		this.inspecteRequisiteService = inspecteRequisiteService;
	}

	public void setThingHandoverService(IThingHandoverService thingHandoverService) {
		this.thingHandoverService = thingHandoverService;
	}

	public void setHouseService(IHouseService houseService) {
		this.houseService = houseService;
	}

	public void setCustomerService(ICustomerService customerService) {
		this.customerService = customerService;
	}

	public void setPerfectItemRequisitionService(
			IPerfectItemRequisitionService perfectItemRequisitionService) {
		this.perfectItemRequisitionService = perfectItemRequisitionService;
	}

	public void setOccupationChargeService(
			IOccupationChargeService occupationChargeService) {
		this.occupationChargeService = occupationChargeService;
	}

	public void setConstService(IConstService constService) {
		this.constService = constService;
	}

	public void setIdentityValidateService(
			IIdentityValidateService identityValidateService) {
		this.identityValidateService = identityValidateService;
	}

	public void setMeterService(IMeterService meterService) {
		this.meterService = meterService;
	}

	/**
	 * 功能描述: 获取缓存中的查询条件 <br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private OccupationQueryConditionVO getIdentityConditionFromCache(){
		OccupationQueryConditionVO obj = (OccupationQueryConditionVO) getAttribute("joinCondition",Scope.SESSION);
		return obj;
	}

	/**
	 * 功能描述:  设置入伙进程<br>
	 * @param processorId
	 * @param queryConditionVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void setProcessorStatus(Long processorId,OccupationQueryConditionVO queryConditionVO){
		SysrefcodeDO sysrefcodeDO =  sysrefcodeService.findSysrefcodeById(processorId);
		if(!BlankUtil.isBlank(sysrefcodeDO)){
			String value = sysrefcodeDO.getValue();
			if(SysrefcodeDO.OM_OCCUPATION_PROCESS_STATE_1.equals(value)){
				queryConditionVO.setIdentityState("1");
			}else if(SysrefcodeDO.OM_OCCUPATION_PROCESS_STATE_2.equals(value)){
				queryConditionVO.setDocState("1");
			}else if(SysrefcodeDO.OM_OCCUPATION_PROCESS_STATE_3.equals(value)){
				queryConditionVO.setChargeState("1");
			}else if(SysrefcodeDO.OM_OCCUPATION_PROCESS_STATE_4.equals(value)){
				queryConditionVO.setInspectCheckinState("1");
			}else if(SysrefcodeDO.OM_OCCUPATION_PROCESS_STATE_5.equals(value)){
				queryConditionVO.setHandoverState("1");
			}
		}
	}

	/**
	 * 功能描述:  构建选择房间以及所属管理房的相关产权房业主信息（个人：姓名,证件类型,证件号码）<br>
	 * （企业：法人姓名,证件类型,证件号码）<br>
	 * @param houseId
	 * @param lists
	 * @param coalitionHouseDomain
	 * Create author:yandawei <br>
	 * Create on:2009-1-9  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void buildClientInfo(Long houseId,List<Object[]> lists,CoalitionHouseDomain coalitionHouseDomain){
		HouseDomain house =	houseService.getHouseById(houseId);
    	List<ParticipantDO> list =  clientRHouseService.getAllOwnerByHouseId(house.getKeyword());
    	for(ParticipantDO participantDO : list){
    		Object[] obj = new Object[6];
	        obj[0] = house.getKeyword();
	    	obj[1] = house.getHouseNumber();
	    	if(BlankUtil.isBlank(coalitionHouseDomain))
	    		obj[2] = "";
	    	else
	    		obj[2] = coalitionHouseDomain.getHouseNumber();
    		try{
    			CustomerVO  customer  = customerService.findIndividualById(participantDO.getParticipantId());
    			if(BlankUtil.isBlank(customer)){
    				customer = customerService.findOrganizationById(participantDO.getParticipantId());
    			}
    			obj[3] = customer.getParticipantName();
	    		obj[4] = customer.getCertificateTypeName();
	    		obj[5] = customer.getCertificateNo();
    		}catch(Exception e){
    			e.printStackTrace();
    		}
    		lists.add(obj);
    	}
	}

	/**
	 * 功能描述:  构造业主房间信息<br>
	 * 将符串业主信息[房间id,房号,管理房号,业主姓名 证件号码(证件类型);...],转换为Set<OccHouseClientInfoVO> 集合
	 * 如果出现字符串中有相同的房间ID存在,则将所有房间ID相同的记录中业主信息部分合并以,隔开做为一条记录保存在集合中
	 * @param clientInfo
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void buildHouseClientInfo(String clientInfo,IdentityValidateVO identityValidateVO)
	{
		if(BlankUtil.isBlank(clientInfo)){
			throw new BusinessException("入伙人信息不能为空");
		}
		String[] strs  = clientInfo.split(";");
		Map<Long ,OccHouseClientInfoVO> map  = new HashMap<Long, OccHouseClientInfoVO>();
		for(String str : strs)
		{
			String[] temps = str.split(",");
			OccHouseClientInfoVO clientInfoVO = map.get(Long.parseLong(temps[0]));
			if(BlankUtil.isBlank(clientInfoVO)){
				clientInfoVO = new OccHouseClientInfoVO();
				clientInfoVO.setIdentityValidateId(null);
				clientInfoVO.setCoalitionHouseNumber(temps[2]);
				identityValidateVO.setCoalitionHouseNumber(temps[2]);
				clientInfoVO.setRealHouseNumber(temps[1]);
				clientInfoVO.setRealHouseClientInfo(temps[3]);
				map.put(Long.parseLong(temps[0]), clientInfoVO);
			}else{
				clientInfoVO.setRealHouseClientInfo(clientInfoVO.getRealHouseClientInfo()+","+temps[3]);
			}
		}
		identityValidateVO.getClientInfos().addAll(map.values());
	}

	/**
	 * 功能描述:  将入伙时房间业主资料信息的产权房业主信息中的逗号换成br<br>
	 * @param set
	 * Create author:yandawei <br>
	 * Create on:2009-1-9  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void splitRealHouseClientInfo(Set<OccHouseClientInfoVO> set){
		for(OccHouseClientInfoVO clientInfoVO : set){
			String realHouseclientInfo = clientInfoVO.getRealHouseClientInfo();
			realHouseclientInfo = realHouseclientInfo.replaceAll(",", "<br>");
			clientInfoVO.setRealHouseClientInfo(realHouseclientInfo);
		}
	}

	/**
	 * 功能描述: 根据身份证ID获取接收人列表(所有业主与委托人) <br>
	 * @param identityId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-9  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private List<ParticipantDO> buildClientInfoList(Long identityId){
		IdentityValidateVO identityValidateVO =  identityValidateService.getIdentityValidateDetail(identityId);
		List<ParticipantDO> list = new ArrayList<ParticipantDO>();
		//委托人
		if("002".equals(identityValidateVO.getTransactJoinIdentity())){
			ParticipantDO participantDO = new IndividualDO();
			participantDO.setParticipantName(identityValidateVO.getClientName());
			list.add(participantDO);
		}
		 List<ParticipantDO> tempList = new ArrayList<ParticipantDO>();
		//按管理房
		if("002".equals(identityValidateVO.getJoinMode())){
			  CoalitionHouseDomain coalitionHouseDomain =	houseService.getCoalition(identityValidateVO.getHouseId());

			  for(HouseDomain house:coalitionHouseDomain.getHouses()){
				  tempList.addAll(clientRHouseService.getAllOwnerByHouseId(house.getKeyword()));
			  }
		}else{
			tempList = clientRHouseService.getAllOwnerByHouseId(identityValidateVO.getHouseId());
		}
		for(ParticipantDO part : tempList){
			list.add(part);
		}
		return list;
	}

	/**
	 * 功能描述: 将缺失物品与发送资料设入资料收发VO中 <br>
	 * @param documentReceiveSendVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void setCollection2DocumentReceiveSend(DocumentReceiveSendVO documentReceiveSendVO){
		Set<SendDocumentItemConfigVO> sendDocumentItemConfigs = new HashSet<SendDocumentItemConfigVO>();
		Set<AbsentDocumentItemConfigVO> absentDocumentItemConfigs = new HashSet<AbsentDocumentItemConfigVO>();
		String absentDocumentItemConfigStr = documentReceiveSendVO.getAbsentDocumentItemConfigStr();
		if(!BlankUtil.isBlank(absentDocumentItemConfigStr)){
			String[] absentDocumentItemConfig = absentDocumentItemConfigStr.split(",");
			for(String str : absentDocumentItemConfig){
				AbsentDocumentItemConfigVO configVO = new AbsentDocumentItemConfigVO();
				configVO.setKeyword(Long.parseLong(str));
				absentDocumentItemConfigs.add(configVO);
			}
			documentReceiveSendVO.setAbsentDocumentItemConfigs(absentDocumentItemConfigs);
		}
		String sendDocumentItemConfigStr = documentReceiveSendVO.getSendDocumentItemConfigStr();
		if(!BlankUtil.isBlank(sendDocumentItemConfigStr)){
			String[] sendDocumentItemConfig = sendDocumentItemConfigStr.split(",");
			for(String str : sendDocumentItemConfig){
				SendDocumentItemConfigVO configVO = new SendDocumentItemConfigVO();
				configVO.setKeyword(Long.parseLong(str));
				sendDocumentItemConfigs.add(configVO);
			}
			documentReceiveSendVO.setSendDocumentItemConfigs(sendDocumentItemConfigs);
		}
	}

	/**
	 * 功能描述:  移交物品字符串格式(移交物品ID,移交物品配置ID,房号,移交数量;)<br>
	 * 如果已存在移交物品则修改其数量,
	 * @param thingHandoverItemStr
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-14  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<ThingHandoverItemVO> buildThingHandoverItemStr2Set(String thingHandoverItemStr,Long identityValidateId){
		Set<ThingHandoverItemVO> set = null;
		if(BlankUtil.isBlank(thingHandoverItemStr)){
			return null;
		}else{
			ThingHandoverVO thingHandover = thingHandoverService.getHandoverByIndentityId(identityValidateId);
			if(BlankUtil.isBlank(thingHandover) ||(!BlankUtil.isBlank(thingHandover)
					&& BlankUtil.isBlank(thingHandover.getThingHandoverItems()))){
				set = getDefaultThingHandoverItemSet(identityValidateId);
			}else{
				set = thingHandover.getThingHandoverItems();
			}
			for(ThingHandoverItemVO handoverItemVO : set){
				String[] strs = thingHandoverItemStr.split(";");
				for(String str : strs){
					String[] objs = str.split(",");
					if(objs[2].equals(handoverItemVO.getHouseNumber()) && objs[1].equals(handoverItemVO.getThingHandoverCongfigId().toString())){
						handoverItemVO.setAmount(new Short(objs[3]));
						set.add(handoverItemVO);
						break;
					}
				}
			}
			return set;
		}
	}


	/**
	 * 功能描述:  设置移交物品默认配置
	 * (在移交物品配置基础上增加房号与移交数量)<br>
	 * @param identityId
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<ThingHandoverItemVO> getDefaultThingHandoverItemSet(Long identityId){
		Set<ThingHandoverItemVO> set = new HashSet<ThingHandoverItemVO>();
		//所有移交物品的配置信息
		List<ThingHandoverCongfigVO> configList =  thingHandoverCongfigService.queryAllThingHandoverCongfig();
	    //身份验证信息
		IdentityValidateVO identityValidateVO =	identityValidateService.getIdentityValidateDetail(identityId);
		for(OccHouseClientInfoVO client  : identityValidateVO.getClientInfos()){
			for(ThingHandoverCongfigVO config : configList){
				ThingHandoverItemVO  item = new ThingHandoverItemVO();
				item.setHouseNumber(client.getRealHouseNumber());
				item.setAmount((short)0);
				item.setThingHandoverCongfigId(config.getKeyword());
				item.setThingHandoverCongfigName(config.getThingHandoverCongfigName());
				item.setThingHandoverCongfigdescription(config.getDescription());
				item.setThingHandoverCongfigsequence(config.getSequence());
				set.add(item);
			}
		}
		return set;
	}

	private List<ThingHandoverItemVO> convertThingHandoverItemSet2List(Set<ThingHandoverItemVO> set){
		List<ThingHandoverItemVO> list = new ArrayList<ThingHandoverItemVO>();
		list.addAll(set);
		return list;
	}

	/**
	 * 功能描述:  设置缓存中的整改项目状态为已保存<br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private boolean setAllStatusToDone(){
		LinkedList<PerfectItemRequisitionVO> oldList = this.getPerfectItemRequisitionListCacheByFlag(false);
		List<PerfectItemRequisitionVO> newList = new ArrayList<PerfectItemRequisitionVO>();
		for (PerfectItemRequisitionVO requisitionVO : oldList) {
			if (ICacheManage.DELETE.equals(requisitionVO.getOpratorStatus())) {
				newList.add(requisitionVO);
			}else{
				requisitionVO.setHasSave(ICacheManage.SAVED);
				requisitionVO.setOpratorStatus(ICacheManage.DONE);
			}
		}
		if (!BlankUtil.isBlank(newList)) {
			oldList.removeAll(newList);
		}
		this.getRequest().getSession().setAttribute(PERFECT_ITEM_REQUSITE_CACHE, oldList);
		return true;
	}

	/**
	 * 功能描述:  设置有关身份验证的信息(房号串1-2A,1-2B,身份验证VO,管理房号,相关房间)<br>
	 * @param identityId 身份验证ID
	 * @param isDistinguishSelf 是否区分选择房间本体与关联房间
	 * @param flag 是否区分入伙方式 为ture
	 * 如果是按产权房入伙,只显示当前房信息
	 * 如果是按管理房入伙,则显示相关房信息
	 * 是否区分入伙方式 为false
	 * 则 只区分本体房间与相关房间
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void setClientBaseInfo(Long identityId,boolean flag){
		IdentityValidateVO identityValidateVO =  identityValidateService.getIdentityValidateDetail(identityId);

		Set<OccHouseClientInfoVO> selfSet = new HashSet<OccHouseClientInfoVO>();
		Set<OccHouseClientInfoVO> otherSet = identityValidateVO.getClientInfos();
		StringBuffer houseNumbers = new StringBuffer("");
		//房间ID串(用于查询走表)
		StringBuffer houseIdStr = new StringBuffer("");
		String coalitionHouseNumber = null;

		String joinModel = identityValidateVO.getJoinMode();
		Iterator it = otherSet.iterator();
		while(it.hasNext()){
			OccHouseClientInfoVO clientInfoVO = (OccHouseClientInfoVO) it.next();
			coalitionHouseNumber = clientInfoVO.getCoalitionHouseNumber();
			houseNumbers.append(clientInfoVO.getRealHouseNumber()).append(",");
			HouseDomain h = houseService.getHouseByNumber(clientInfoVO.getRealHouseNumber());
			houseIdStr.append(h.getKeyword()).append(",");
			//flag = ture && "001".equals(joinModel),结果来源于selfSet
			//flag = ture && "002".equals(joinModel),结果来源于otherSet
			if(flag && "001".equals(joinModel)){
				//产权房入伙
				if(clientInfoVO.getRealHouseNumber().equals(identityValidateVO.getHouseNumber())){
					selfSet.add(clientInfoVO);
					it.remove();
				}
			}
			//flag = false 结果来源于selfSet,与otherSet(主要用于身份验证修改)
			if(flag == false ){
				if(clientInfoVO.getRealHouseNumber().equals(identityValidateVO.getHouseNumber())){
					selfSet.add(clientInfoVO);
					it.remove();
				}
			}
		}
		//按管理房入伙
//		if("002".equals(identityValidateVO.getJoinMode())){
//
//			CoalitionHouseDomain coalitionHouse =	houseService.getCoalition(identityValidateVO.getHouseId());
//			for(HouseDomain house : coalitionHouse.getHouses()){
//				houseIdStr.append(house.getKeyword()).append(",");
//			}
//		}else{
//			houseIdStr.append(identityValidateVO.getHouseId()).append(",");
//		}
		if(houseIdStr.length()>0){
			houseIdStr = houseIdStr.deleteCharAt(houseIdStr.length()-1);
		}
		if(houseNumbers.length()>0){
			houseNumbers = houseNumbers.deleteCharAt(houseNumbers.length()-1);
		}


		splitRealHouseClientInfo(otherSet);
		splitRealHouseClientInfo(selfSet);
		if(flag){
			if("001".equals(joinModel)){
				setAttribute("clientInfoSet", selfSet);
			}else{
				setAttribute("clientInfoSet", otherSet);
			}
		}else{
			//相关房间信息
			setAttribute("clientInfoSet", otherSet);
			//本体房间信息
			setAttribute("selfClientSet", selfSet);
		}

		setAttribute("houseIds", houseIdStr);
		//产权房号串
		setAttribute("houseNumbers", houseNumbers.toString());
		//身份验证
		setAttribute("identityValidate",identityValidateVO);
		//管理房号
		setAttribute("coalitionHouseNumber", coalitionHouseNumber);
	}


	/**
	 * 功能描述:  新增整改项目到缓存<br>
	 * @param perfectItemRequisitionVO
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private boolean addPerfectItemRequistionToCache(PerfectItemRequisitionVO perfectItemRequisitionVO,boolean isFirst){
		boolean result = false;
		if(BlankUtil.isBlank(perfectItemRequisitionVO))
			return false;
		LinkedList<PerfectItemRequisitionVO> list = (LinkedList<PerfectItemRequisitionVO>) getRequest().getSession().getAttribute(PERFECT_ITEM_REQUSITE_CACHE);
		if(list == null){
			list = new LinkedList<PerfectItemRequisitionVO>();
		}else if(list.contains(perfectItemRequisitionVO)){
			result = this.JudgeDeletePerfectItemRequisitionFromCache(perfectItemRequisitionVO)==null?false:true;
			return result;
		}
		perfectItemRequisitionVO.setHasSave(ICacheManage.UNSAVE);//未保存过
		perfectItemRequisitionVO.setOpratorStatus(ICacheManage.ADD);//操作状态
		perfectItemRequisitionVO.setIndex(this.generationCacheIndex(list));//设置索引
		if (isFirst) {
			list.addFirst(perfectItemRequisitionVO);
		}else {
			list.addLast(perfectItemRequisitionVO);
		}
		Collections.sort(list);
		this.getRequest().getSession().setAttribute(PERFECT_ITEM_REQUSITE_CACHE, list);
		result = true;
		return result;
	}

	/**
     * 功能描述:  修改缓存中指定的整改项目<br>
     * @param perfectItemRequisitionVO
     * @return
     * Create author:yandawei <br>
     * Create on:2009-1-6  <br>
     * Edit author:  <br>
     * Edit on:    <br>
     * Why:     <br>
     */
	private boolean editPerfectItemRequistionFromCache(PerfectItemRequisitionVO perfectItemRequisitionVO){
		LinkedList<PerfectItemRequisitionVO> list = this.getPerfectItemRequisitionListCacheByFlag(false);
		boolean returnValue =  false;
		if (!list.contains(perfectItemRequisitionVO)) {
			return returnValue;
		}
		PerfectItemRequisitionVO tempRequist = null;
		//判断是否存在
		for(PerfectItemRequisitionVO itemRequisitionVO : list){
			if (itemRequisitionVO.getIndex().equals(perfectItemRequisitionVO.getIndex())) {
				tempRequist =itemRequisitionVO;
				editPerfectItemRequistionInner(perfectItemRequisitionVO, tempRequist);
				tempRequist.setOpratorStatus(ICacheManage.EDIT);//操作状态
				returnValue = true;
				this.getRequest().getSession().setAttribute(PERFECT_ITEM_REQUSITE_CACHE, list);
				break;
			}
		}
		return returnValue;
	}

	/**
	 * 功能描述:  删除缓存中指定的整改项目<br>
	 * @param perfectItemRequisitionVO
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private boolean deletePerfectItemRequistionFromCache(PerfectItemRequisitionVO perfectItemRequisitionVO) {
		LinkedList<PerfectItemRequisitionVO> list = this.getPerfectItemRequisitionListCacheByFlag(false);
		boolean flag =  false;
		if (!list.contains(perfectItemRequisitionVO)) {
			return flag;
		}
		for (PerfectItemRequisitionVO requisitionVO : list) {
			if (requisitionVO.getIndex().equals(perfectItemRequisitionVO.getIndex())) {
				if (ICacheManage.UNSAVE.equals(requisitionVO.getHasSave())) {
					list.remove(requisitionVO);
					this.getRequest().getSession().setAttribute(PERFECT_ITEM_REQUSITE_CACHE, list);
				}else{
					requisitionVO.setOpratorStatus(ICacheManage.DELETE);//操作状态
				}
				flag = true;
				break;
			}
		}
		return flag;
	}

	/**
	 * 功能描述:  修改整改项目<br>
	 * @param source
	 * @param target
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void editPerfectItemRequistionInner(final PerfectItemRequisitionVO source,PerfectItemRequisitionVO target){
		PopulateUtil.populate(source, target);
	}


	/**
	 * 功能描述: 生成缓存中的序号 <br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-16  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Integer generationCacheIndex(LinkedList<PerfectItemRequisitionVO> list){
		if (list == null) {
			return -1;
		}else if (0 == list.size()) {
			return 1;
		}
		Integer max = 1;
		for (ICacheManage manage : list) {
			if (max < manage.getIndex()) {
				max = manage.getIndex();
			}
		}
		return max + 1;
	}

	/**
	 * 功能描述: 判断一个整改项目是不是存在于缓存中的已被置为删除状态的数据，如果存在就恢复过来 <br>
	 * @param perfectItemRequisitionVO
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private PerfectItemRequisitionVO JudgeDeletePerfectItemRequisitionFromCache(PerfectItemRequisitionVO perfectItemRequisitionVO){
		List<PerfectItemRequisitionVO> list = this.getDeletePerfectItemRequisitionListCache();
		for (PerfectItemRequisitionVO tempchvo : list) {
			//如果存在于缓存中，是删除状态的，则恢复过来，并设置持久属性为SAVED，状态属性为EDIT
			if (perfectItemRequisitionVO.equals(tempchvo)) {
				tempchvo.setHasSave(ICacheManage.SAVED);
				tempchvo.setOpratorStatus(ICacheManage.EDIT);
				return tempchvo;
			}
		}
		return null;
	}

	/**
	 * 功能描述: 得到缓存中已删除的整改项目列表 <br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private LinkedList<PerfectItemRequisitionVO> getDeletePerfectItemRequisitionListCache() {
		//得到全部的
		LinkedList<PerfectItemRequisitionVO> allList=this.getPerfectItemRequisitionListCacheByFlag(false);
		ListIterator<PerfectItemRequisitionVO> listIter = allList.listIterator();
		while (listIter.hasNext()) {
			PerfectItemRequisitionVO requisitionVO = listIter.next();
			//把缓存中住户资料操作状态为未删除的过滤掉
			if (!ICacheManage.DELETE.equals(requisitionVO.getOpratorStatus())) {
				listIter.remove();
			}
		}
		return allList;
	}

	/**
	 * 功能描述:  得到缓存中整改项目列表，如果没有数据，
	 * 此方法返回一个实例化的空列表容器,如果operatorFlag参数为<b><i>true</i></b>值，
	 * 则会返回一个过滤了删除状态记录的列表，否则完整返回<br>
	 * @param operatorFlag
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private LinkedList<PerfectItemRequisitionVO> getPerfectItemRequisitionListCacheByFlag(boolean operatorFlag) {
		LinkedList<PerfectItemRequisitionVO> list = (LinkedList<PerfectItemRequisitionVO>)
			this.getRequest().getSession().getAttribute(PERFECT_ITEM_REQUSITE_CACHE);
		if (!operatorFlag) {
			return list==null?new LinkedList<PerfectItemRequisitionVO>():list;
		}
		LinkedList<PerfectItemRequisitionVO> noDelList = new LinkedList<PerfectItemRequisitionVO>();
		//把缓存中住户资料操作状态为已删除的过滤掉
		if (list != null) {
			for (PerfectItemRequisitionVO requisitionVO : list) {
				if (ICacheManage.DELETE.equals(requisitionVO.getOpratorStatus())) {
					continue;
				}
				noDelList.add(requisitionVO);
			}
		}
		return noDelList;
	}

	/**
	 * 功能描述: 根据下标index从缓存中获取指定整改项目 <br>
	 * @param index
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private PerfectItemRequisitionVO getPerfectItemRequisitionByIndexFromCache(Integer index) {
		if (BlankUtil.isBlank(index)) {
			return null;
		}
		LinkedList<PerfectItemRequisitionVO> list = this.getPerfectItemRequisitionListCacheByFlag(false);
		if (list == null) {
			return null;
		}
		for (PerfectItemRequisitionVO vo : list) {
			if (index.equals(vo.getIndex())) {
				return vo;
			}
		}
		return null;
	}


	/**
	 * 功能描述: 计算缓存中的记录总数 <br>
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Integer getTotalRowsFromCache(){
		LinkedList<PerfectItemRequisitionVO> list = (LinkedList<PerfectItemRequisitionVO>)
			this.getRequest().getSession().getAttribute(PERFECT_ITEM_REQUSITE_CACHE);
		int totalRows=0;
		if (list!=null) {
			totalRows = list.size();
			for (PerfectItemRequisitionVO manage : list) {
				if (ICacheManage.DELETE.equals(manage.getOpratorStatus())) {
					totalRows--;
				}
			}
		}
		return totalRows;
	}

	/**
	 * 功能描述:  组装走表记录(格式:走表主键,房屋ID,房号,管理房号,水表ID,水表读数,走表ID,电表读数;...)<br>
	 * @param meterCardinalStr
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<MeterCardinalNumberVO> buildMeterCardinalByStr(String meterCardinalStr){
		Set<MeterCardinalNumberVO> set= new HashSet<MeterCardinalNumberVO>();
		String[] meterCardinals = meterCardinalStr.split(";");
		for(String meterCardinal : meterCardinals){
			String[] strs = meterCardinal.split(",");
			MeterCardinalNumberVO cardinalNumberVO = new MeterCardinalNumberVO();
			cardinalNumberVO.setKeyword(strs[0].length() == 0 ? null:Long.parseLong(strs[0]));
			cardinalNumberVO.setHouseId(strs[1].length() == 0 ? null:Long.parseLong(strs[1]));
			cardinalNumberVO.setHouseNumber(strs[2]);
			cardinalNumberVO.setCoalitionHouseNumber(strs[3]);
			cardinalNumberVO.setWaterMeterId(strs[4].length() == 0 ? null:Long.parseLong(strs[4]));
			cardinalNumberVO.setWaterMeter(new BigDecimal(strs[5]));
			cardinalNumberVO.setAmmeterId(strs[6].length() == 0 ? null:Long.parseLong(strs[6]));
			cardinalNumberVO.setAmmeter(new BigDecimal(strs[7]));
			cardinalNumberVO.setCreator(getUserId());
			cardinalNumberVO.setModifier(getUserId());
			set.add(cardinalNumberVO);
		}
		return set;
	}

	/**
	 * 功能描述:  将整改项目的List集合转为Set集合<br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<PerfectItemRequisitionVO> convertPerfectItemList2Set(LinkedList<PerfectItemRequisitionVO> list){
		if(list == null)
			return null;
		Set<PerfectItemRequisitionVO> set = new HashSet<PerfectItemRequisitionVO>();
		for(PerfectItemRequisitionVO vo : list){
			set.add(vo);
		}
		return set;
	}

	/**
	 * 功能描述:  查找指定房间的当前走表读数<br>
	 * @param houseId 房间ID
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2009-1-7  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private MeterCardinalNumberVO copyMeterDataToMeterCardinalBy(String houseId,MeterCardinalNumberVO meterVO){
		Long id = null;
		if(!BlankUtil.isBlank(houseId)){
			id = Long.parseLong(houseId);
		}
		List<MeterVO> source = meterService.getMeterListByhouseId(id);
		if(!BlankUtil.isBlank(meterVO)){
			for(MeterVO meter : source){
				if(meter.getHouseNumber().equals(meterVO.getHouseNumber())){
					meterVO.setHouseId(id);
					if("001".equals(meter.getMeterTypeCode())){
						meterVO.setWaterMeterId(meter.getKeyword());
						continue;
					}else if("002".equals(meter.getMeterTypeCode())){
						meterVO.setAmmeterId(meter.getKeyword());
						continue;
					}
				}
			}
			return meterVO;
		}else{
			MeterCardinalNumberVO target = new MeterCardinalNumberVO();
			if(BlankUtil.isBlank(source)){
				return target;
			}else{
				for(MeterVO meter : source){
					target.setHouseId(id);
					target.setHouseNumber(meter.getHouseNumber());
					if("001".equals(meter.getMeterTypeCode())){
						target.setWaterMeterId(meter.getKeyword());
						target.setWaterMeter(meter.getBase() == null ?new BigDecimal(0.00):meter.getBase());
						continue;
					}else if("002".equals(meter.getMeterTypeCode())){
						target.setAmmeterId(meter.getKeyword());
						target.setAmmeter(meter.getBase() == null ?new BigDecimal(0.00):meter.getBase());
						continue;
					}
				}
				return target;
			}
		}
	}

	/**
	 * 功能描述:  清空整改项目缓存<br>
	 *
	 * Create author:yandawei <br>
	 * Create on:2009-1-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void clearCache() {
		getRequest().getSession().removeAttribute(PERFECT_ITEM_REQUSITE_CACHE);
	}

	public void setPerfectItemDispatchService(
			IPerfectItemDispatchService perfectItemDispatchService) {
		this.perfectItemDispatchService = perfectItemDispatchService;
	}



}
